<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=0,user-scalable=0">
    [#include "/wap/include/static.html"]
    <link rel="stylesheet" href="${path}/resources/wap/css/logIn/logn.css"/>
    <script src="${path}/resources/js/carousel.js" type="text/javascript"></script>
    <script type="text/javascript" src="${path}/resources/js/rsa/jsbn.js"></script>
    <script type="text/javascript" src="${path}/resources/js/rsa/prng4.js"></script>
    <script type="text/javascript" src="${path}/resources/js/rsa/rng.js"></script>
    <script type="text/javascript" src="${path}/resources/js/rsa/rsa.js"></script>
    <script type="text/javascript" src="${path}/resources/js/rsa/base64.js"></script>
</head>
<body>

<!--头部-->
<header>
    <div class="left">
        <img id="goBack" src="${path}/resources/wap/img/me/blank.png">
    </div>
    <div class="center" onclick="window.location.href='/wap/member/common/register'">
       注册
    </div>
</header>
<div class="logo">
    <img src="${path}${p2p_get_global('logo')}" width="98px" height="99px" title="">
    [#--<img src="${path}/resources/wap/img/logIn/logo.jpg" alt="">--]
</div>
<!--输入框-->
<form class="layui-form">
<div id="matter">

    <div class="matter-option">
        <label for="name"><img src="${path}/resources/wap/img/logIn/account.png" alt="图片"/></label><input id="name" name="username" placeholder="请输入的账户名">
    </div>
    <div class="matter-option">
        <input name="password" type="password" style="display: none">
        <label for="psd"><img src="${path}/resources/wap/img/logIn/psd.png" alt="图片"/></label><input id="pwd" type="password" name="password" placeholder="请输入密码">
    </div>

</div>

    <!--按钮-->
<div class="button">
    <button lay-filter="MainForm" lay-submit  id="submit" type="submit">确定</button>
</div>
</form>
<!--忘记密码-->
<div class="forget-psd">
    <a href="${path}/wap/forget/safe">忘记密码？</a>
</div>
<script type="text/javascript">
    layui.use('form', function(){
        var form = layui.form(), $=layui.jquery;

        form.on('submit(MainForm)', function(data){
            console.log("password="+data.field.password);
            var index = layer.load();
            $.ajax({
                url: "${path}/common/key",
                type: "GET",
                dataType: "json",
                cache: false,
                beforeSend: function() {
                    $("#submit").attr("disabled", "disabled");
                },
                success: function(resultData) {
                    var rsaKey = new RSAKey();
                    rsaKey.setPublic(b64tohex(resultData.modulus), b64tohex(resultData.exponent));
                    var pass = hex2b64(rsaKey.encrypt(data.field.password));
                    ajax({
                        url: "${path}/wap/loginVerify",
                        type: "POST",
                        dataType: "json",
                        cache: false,
                        data:{"username":data.field.username,"password":pass, "captcha":data.field.captcha},
                        success: function(result) {
                            layer.close(index);
                            $("#submit").removeAttr("disabled");
                            if(result && result.type && result.type == "success"){
                                var url = GetQueryString("redirectUrl");
                                if(url==''||url==null){
                                    location.href = "${path}/wap/member/";
                                }else{
                                    location.href = url;
                                }
                            }else{
                                layer.msg(result.content,{icon:2});

                            }
                        },error:function(result){
                            layer.close(index);

                        }
                    });
                }
            });
            return false;
        });
    });


    function GetQueryString(name)
    {
        var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        if(r!=null)return  unescape(r[2]); return null;
    }

</script>
</body>
</html>